package com.smart.util;

import java.util.List;
import java.util.ArrayList;
import java.io.Serializable;

/**
 * @author lgb
 * @date 2020年6月10日 上午10:17:05
 * Copyright (C) 深圳工勘科技
 * @说明: @param <T> 分页
 **/
public class Page<T> implements Serializable {

	private static final long serialVersionUID = -7846359838807658041L;
	private Long totalCount;
	private int pageCount;
	private List<T> content = new ArrayList<>();
	private Pageable pageable;

	public Page() {
		this.totalCount = 0L;
		this.pageable = new Pageable();
		this.pageCount = 1;
	}

	public List<T> getContent() {
		return content;
	}

	public void setContent(List<T> content) {
		this.content = content;
	}

	public Pageable getPageable() {
		return pageable;
	}

	public void setPageable(Pageable pageable) {
		this.pageable = pageable;
	}

	public Page(List<T> list,Pageable p,Long totalCount) {
		this.content.addAll(list);
		this.pageable = p;
		this.totalCount = totalCount;
		double $total = totalCount;
		double $limit = this.getPageable().getLimit();
		double $count = $total / $limit;
		this.pageCount = (int) Math.ceil($count);
	}

	public Long getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(Long totalCount) {
		this.totalCount = totalCount;
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}
}